﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace Infrastructure.PortalBusiness
{
    public class DateModelBinder : IModelBinder
    {
        public object BindModel(
            ControllerContext controllerContext,
            ModelBindingContext bindingContext
            )
        {
            var values = controllerContext.RouteData.Values;
            int year = Int32.Parse((string)values["year"]);
            int month = Int32.Parse((string)values["month"]);
            int day = Int32.Parse((string)values["day"]);
            return new DateTime(year, month, day);
        }
    }
}